package com.bub.pay.api.controller;

import com.bub.pay.core.entity.dto.merchant.MerchantUserDTO;
import com.bub.pay.core.entity.dto.merchant.NewBuiltMerchantEmployeeDTO;
import com.bub.pay.core.entity.dto.merchant.ResetPasswordDTO;
import com.bub.pay.core.entity.vo.merchant.MerchantEmployeeVo;
import com.bub.pay.core.manager.merchant.MerUserManager;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Description 商户员工管理Controller
 * @Auhtor John
 */
@RestController
@RequestMapping("/merchant/empManagement")
public class MerEmployeeManagementController {

    @Autowired
    private MerUserManager merUserManager;

    @PostMapping("/employeeInfo")
    public Object employeeInfo(@RequestBody MerchantEmployeeVo vo){
        PageHelper.startPage(vo.getPageNo(),vo.getPageSize());
        PageInfo<MerchantUserDTO> pageInfo = new PageInfo<>(merUserManager.selectMerchantUser(vo));
        return pageInfo;
    }

    @PostMapping("/updateEmployeeStatus")
    public Object updateEmployeeStatus(@RequestBody MerchantEmployeeVo vo){
        return merUserManager.updateMerchantEmployeeStatus(vo);
    }

    @PostMapping("/deleteEmployee")
    public Object deleteEmployee(@RequestBody MerchantEmployeeVo vo){
        return merUserManager.deleteMerchantEmployee(vo);
    }

    @PostMapping("/updateEmployee")
    public Object updateEmployee(@RequestBody MerchantEmployeeVo vo){
        return merUserManager.updateMerchantEmployee(vo);
    }

    @PostMapping("/resetPassword")
    public Object resetPassword(@RequestBody ResetPasswordDTO dto){
        return merUserManager.resetMerchantPassword(dto);
    }

    @PostMapping("/addEmployee")
    public Object addEmployee(@Valid @RequestBody NewBuiltMerchantEmployeeDTO dto){
        return merUserManager.newBuiltMerchantEmployee(dto);
    }
}
